home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / pd / serien / purity / nr.10 / medplayerlibrary / medplay1.0c.p < prev    next >
Text File  |  1995-04-19  |  3KB  |  113 lines

  1. program medplay3;
  2.  
  3.   *  Medplay.p ,  1993 by Diesel,  (P)1993 in the Pascal-FD-Serie  *
  4.   *  "Purity". Feel free 2 spread this !  [ This version 1.0c is   *
  5.   *  only 4 use in CLI ]                       Bernd K., 1993      * }
  6.  
  7.  
  8. *  This example uses the medplayer.library . Compiled with PCQ-  *
  9.   *  Pascal V1.2 .                                                 * }
  10.  
  11.  
  12.  
  13. {$I "Include:Libraries/medplayer.i"  }
  14. {$I "Include:libraries/dos.i"   }
  15. {$I "Include:exec/Libraries.i"  }
  16. {$I "Include:utils/Parameters.i"  }
  17. {$I "Include:intuition/intuition.i"  }
  18.  
  19. Const
  20.     NW : NewWindow = ( 10,20,350,11, 0,2, CloseWindow_f,
  21.             WindowDrag+WindowDepth+WindowClose+RMBTrap,
  22.             NIL, NIL, NIL,NIL, NIL,
  23.             0,0,0,0, WBenchScreen_f);
  24.  
  25. VAR
  26.     GP      : Integer;
  27.     name      : String;            { für Argument    }
  28.     buf      : Array[0..99] of Char;    { vom CLI    }
  29.  
  30.     module      : MMD0Ptr;            { ->Song-Record }
  31.     Win      : WindowPtr;
  32.     WMsgPort  : MsgPortPtr;
  33.     Msg      : IntuiMessagePtr;
  34.  
  35.  
  36. * Zum sauberen Verlassen des Programms : * }
  37.  
  38. Procedure CleanExit( why : String; rt : Integer);
  39. Begin
  40.       { * Window zu * }
  41.     If Win <> NIL        then CloseWindow( Win );
  42.       { * Player entfernen * }
  43.     If GP = 0        then FreePlayer;
  44.       { * Song adios * }
  45.     If module <> NIL    then UnloadModule( module );
  46.       { * Library zu * }
  47.     If MEDPlayerBase <> NIL    then CloseLibrary( MEDPlayerBase );
  48.       { * ggf. Msg ausgeben * }
  49.     If why <> NIL        then Begin
  50.       write( why );
  51.       Delay(50);
  52.     End;
  53.  
  54.     Exit( rt );        { * Bye ! * }
  55. End;
  56.  
  57. begin
  58.     GP := -1;
  59.     name := Adr( buf );
  60.     GetParam( 1, name );        { * CLI-Arg. holen * }
  61.     if buf[0] = chr(0) then
  62.       CleanExit("Medplay 1.0c, 1993 by Diesel\nUsage: Medplay med-modulename\n\n",0);
  63.  
  64.                     { * Library aufmachen, logo * }
  65.     MEDPlayerBase := OpenLibrary( medname, 0 );
  66.     if MEDPlayerBase = NIL then
  67.       CleanExit("Cannot open medplayer.library\n", 10);
  68.  
  69.  
  70.     GP := GetPlayer(0);        { * Player installieren * }
  71.     If  GP <> 0  then
  72.       CleanExit("Cannot init player\n",0);
  73.  
  74.  
  75.     module := LoadModule( name );    { * Song laden * }
  76.     If module = NIL then
  77.       CleanExit("Cannot load module\n",0);
  78.  
  79.     NW.Title := name;        { * Fenster auf * }
  80.     Win := OpenWindow( Adr(NW) );
  81.     If Win = NIL then CleanExit("Cannot open window\n",0);
  82.  
  83.     PlayModule(module);        { * Mucke ab ! * }
  84.  
  85.  
  86.     WMsgPort:=Win^.UserPort;    { * MsgPort holen * }
  87.  
  88.                     { * Messages holen * }
  89.     Repeat
  90.       Msg := IntuiMessagePtr( WaitPort( WMsgPort ));
  91.       Msg := IntuiMessagePtr(   GetMsg( WMsgPort ));
  92.     Until Msg <> NIL ;
  93.  
  94.     { * Einzige mögl. Msg = CloseWindow !  * }
  95.     { * Sicherheitshalber nachfragen, ob noch CW-Msg`s da sind : * }
  96.  
  97.     REPEAT
  98.       ReplyMsg(MessagePtr(Msg));            { * Msg beantworten    * }
  99.       Msg:=IntuiMessagePtr(GetMsg(WMsgPort));   { * Msg holen, = NIL ? * }
  100.     UNTIL Msg = NIL;
  101.      CloseWindow( Win );        { * Fenster zu * }
  102.     Win := NIL;
  103.  
  104.  
  105.     DimOffPlayer(10);        { * Song ausblenden * }
  106.     Delay(100);            { * 2 sec. warten   * }
  107.  
  108.  
  109.     CleanExit( NIL, 0 );        { * Und tschüß ! * }
  110. end.
  111.  
  112.